package com.ctsi.oauth.controller;

import com.ctsi.framework.common.exception.CoreErrorConstant;
import com.ctsi.framework.common.exception.ExceptionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @author zhangjw
 */
@RestController
public class UserController {

    @Autowired
    private ExceptionFactory exceptionFactory;

    @GetMapping(value = "/user")
    public Principal user(Principal user) {
        return user;
    }

    @GetMapping(value = "/login")
    public void login(){
        exceptionFactory.throwAuthError(CoreErrorConstant.HEADER_TOKEN_ILLEGAL);
    }

}
